<template>
  <div class="server">
    <el-row :gutter="12">
      <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="bottom12">
        <cfCard title='CPU' class='page-container-top'>
          <div slot='content' style="width: 100%;overflow-x: overlay;">
            <table cellspacing="0" class="el-table el-table--enable-row-hover el-table--medium" style="width: 100%">
              <thead>
                <tr>
                  <th class="el-table__cell is-leaf"><div class="cell">属性</div></th>
                  <th class="el-table__cell is-leaf"><div class="cell">值</div></th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td class="el-table__cell is-leaf"><div class="cell">核心数</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.cpu">{{ server.cpu.cpuNum }}</div></td>
                </tr>
                <tr>
                  <td class="el-table__cell is-leaf"><div class="cell">用户使用率</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.cpu">{{ server.cpu.used }}%</div></td>
                </tr>
                <tr>
                  <td class="el-table__cell is-leaf"><div class="cell">系统使用率</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.cpu">{{ server.cpu.sys }}%</div></td>
                </tr>
                <tr>
                  <td class="el-table__cell is-leaf"><div class="cell">当前空闲率</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.cpu">{{ server.cpu.free }}%</div></td>
                </tr>
              </tbody>
            </table>
          </div>
        </cfCard>
      </el-col>
      <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="bottom12">
        <cfCard title='内 存' class='page-container-top'>
          <div slot='content' style="width: 100%;overflow-x: overlay;">
            <table cellspacing="0" class="el-table el-table--enable-row-hover el-table--medium" style="width: 100%">
              <thead>
                <tr>
                  <th class="el-table__cell is-leaf"><div class="cell">属性</div></th>
                  <th class="el-table__cell is-leaf"><div class="cell">内存</div></th>
                  <th class="el-table__cell is-leaf"><div class="cell">JVM</div></th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td class="el-table__cell is-leaf"><div class="cell">总内存</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.mem">{{ server.mem.total }}G</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.total }}M</div></td>
                </tr>
                <tr>
                  <td class="el-table__cell is-leaf"><div class="cell">已用内存</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.mem">{{ server.mem.used}}G</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.used}}M</div></td>
                </tr>
                <tr>
                  <td class="el-table__cell is-leaf"><div class="cell">剩余内存</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.mem">{{ server.mem.free }}G</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.free }}M</div></td>
                </tr>
                <tr>
                  <td class="el-table__cell is-leaf"><div class="cell">使用率</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.mem" :class="{'text-danger': server.mem.usage > 80}">{{ server.mem.usage }}%</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm" :class="{'text-danger': server.jvm.usage > 80}">{{ server.jvm.usage }}%</div></td>
                </tr>
              </tbody>
            </table>
          </div>
        </cfCard>
      </el-col>
      <el-col :span="24" class="bottom12">
        <cfCard title='服务器信息' class='page-container-top'>
          <div slot='content' style="width: 100%;overflow-x: overlay;">
            <table cellspacing="0" class="el-table el-table--enable-row-hover el-table--medium" style="width: 100%">
              <tbody>
                <tr>
                  <td class="el-table__cell is-leaf" style="min-width: 120px"><div class="cell">采购方</div></td>
                  <td class="el-table__cell is-leaf" style="min-width: 140px">
                    <div class="cell">
                      <div>
                        <span class="label">名 称：</span><span class="value">张三</span>
                      </div>
                      <div>
                        <span class="label">纳税人识别号：</span><span class="value">张三</span>
                      </div>
                      <div>
                        <span class="label">地址、电话：</span><span class="value">张三</span>
                      </div>
                      <div>
                        <span class="label">开户行及账号：</span><span class="value">张三</span>
                      </div>
                    </div>
                  </td>
                  <td class="el-table__cell is-leaf" style="min-width: 120px"><div class="cell">密码区</div></td>
                  <td class="el-table__cell is-leaf" style="min-width: 120px">
                    <div class="cell">
                      ******************
                      ******************
                    </div>
                  </td>
                </tr>
                <tr>
                  <td class="el-table__cell is-leaf"><div class="cell">货物或应税劳务、服务名称</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">规格型号</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">单位</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">数量</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">单价</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">金额</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">税率</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">税额</div></td>
                </tr>
                <tr>
                  <td class="el-table__cell is-leaf"><div class="cell">货物或应税劳务、服务名称</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">规格型号</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">单位</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">数量</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">单价</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">金额</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">税率</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">税额</div></td>
                </tr>
                <tr>
                  <td class="el-table__cell is-leaf"><div class="cell">合 计</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell"></div></td>
                  <td class="el-table__cell is-leaf"><div class="cell"></div></td>
                  <td class="el-table__cell is-leaf"><div class="cell"></div></td>
                  <td class="el-table__cell is-leaf"><div class="cell"></div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">¥ 100.00</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell"></div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">¥ 100.00</div></td>
                </tr>
                <tr>
                  <td class="el-table__cell is-leaf"><div class="cell">价税合计（大写）</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">壹佰元整</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell"></div></td>
                  <td class="el-table__cell is-leaf"><div class="cell"></div></td>
                  <td class="el-table__cell is-leaf"><div class="cell"></div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">（小写）</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">¥ 100.00</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell"></div></td>
                </tr>
                <tr>
                  <td class="el-table__cell is-leaf" style="min-width: 120px"><div class="cell">销售方</div></td>
                  <td class="el-table__cell is-leaf" style="min-width: 140px">
                    <div class="cell">
                      <div>
                        <span class="label">名 称：</span><span class="value">张三</span>
                      </div>
                      <div>
                        <span class="label">纳税人识别号：</span><span class="value">张三</span>
                      </div>
                      <div>
                        <span class="label">地址、电话：</span><span class="value">张三</span>
                      </div>
                      <div>
                        <span class="label">开户行及账号：</span><span class="value">张三</span>
                      </div>
                    </div>
                  </td>
                  <td class="el-table__cell is-leaf" style="min-width: 120px"><div class="cell">备 注</div></td>
                  <td class="el-table__cell is-leaf" style="min-width: 120px">
                    <div class="cell">
                      ******************
                      ******************
                    </div>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </cfCard>
      </el-col>
      <el-col :span="24" class="bottom12">
        <cfCard title='Java虚拟机信息' class='page-container-top'>
          <div slot='content' style="width: 100%;overflow-x: overlay;">
            <table cellspacing="0" class="el-table el-table--enable-row-hover el-table--medium" style="width: 100%">
              <tbody>
                <tr>
                  <td class="el-table__cell is-leaf" style="min-width: 120px"><div class="cell">Java名称</div></td>
                  <td class="el-table__cell is-leaf" style="min-width: 120px"><div class="cell" v-if="server.jvm">{{ server.jvm.name }}</div></td>
                  <td class="el-table__cell is-leaf" style="min-width: 120px"><div class="cell">Java版本</div></td>
                  <td class="el-table__cell is-leaf" style="min-width: 120px"><div class="cell" v-if="server.jvm">{{ server.jvm.version }}</div></td>
                </tr>
                <tr>
                  <td class="el-table__cell is-leaf"><div class="cell">启动时间</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.startTime }}</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">运行时长</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.runTime }}</div></td>
                </tr>
                <tr>
                  <td colspan="1" class="el-table__cell is-leaf"><div class="cell">安装路径</div></td>
                  <td colspan="3" class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.home }}</div></td>
                </tr>
                <tr>
                  <td colspan="1" class="el-table__cell is-leaf"><div class="cell">项目路径</div></td>
                  <td colspan="3" class="el-table__cell is-leaf"><div class="cell" v-if="server.sys">{{ server.sys.userDir }}</div></td>
                </tr>
                <tr>
                  <td colspan="1" class="el-table__cell is-leaf"><div class="cell">运行参数</div></td>
                  <td colspan="3" class="el-table__cell is-leaf"><div class="cell" v-if="server.jvm">{{ server.jvm.inputArgs }}</div></td>
                </tr>
              </tbody>
            </table>
          </div>
        </cfCard>
      </el-col>
      <el-col :span="24">
        <cfCard title='磁盘状态' class='page-container-top'>
          <div slot='content' style="width: 100%;overflow-x: overlay;">
            <table cellspacing="0" class="el-table el-table--enable-row-hover el-table--medium" style="width: 100%">
              <thead>
                <tr>
                  <th class="el-table__cell el-table__cell is-leaf" style="min-width: 120px;"><div class="cell">盘符路径</div></th>
                  <th class="el-table__cell is-leaf" style="min-width: 100px;"><div class="cell">文件系统</div></th>
                  <th class="el-table__cell is-leaf" style="min-width: 120px;"><div class="cell">盘符类型</div></th>
                  <th class="el-table__cell is-leaf" style="min-width: 120px;"><div class="cell">总大小</div></th>
                  <th class="el-table__cell is-leaf" style="min-width: 120px;"><div class="cell">可用大小</div></th>
                  <th class="el-table__cell is-leaf" style="min-width: 120px;"><div class="cell">已用大小</div></th>
                  <th class="el-table__cell is-leaf" style="min-width: 120px;"><div class="cell">已用百分比</div></th>
                </tr>
              </thead>
              <tbody v-if="server.sysFiles">
                <tr v-for="(sysFile, index) in server.sysFiles" :key="index">
                  <td class="el-table__cell is-leaf"><div class="cell">{{ sysFile.dirName }}</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">{{ sysFile.sysTypeName }}</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">{{ sysFile.typeName }}</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">{{ sysFile.total }}</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">{{ sysFile.free }}</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell">{{ sysFile.used }}</div></td>
                  <td class="el-table__cell is-leaf"><div class="cell" :class="{'text-danger': sysFile.usage > 80}">{{ sysFile.usage }}%</div></td>
                </tr>
              </tbody>
            </table>
          </div>
        </cfCard>
      </el-col>
    </el-row>
    
  </div>
</template>

<script>
import { getServer } from "@/api/monitor/server";
  export default {
    name: "Server",
    data() {
      return {
        server: [],  /**服务器信息*/
      }
    },
    created() {
      this.getList();
      this.openLoading();
    },
    methods: {
      async getList() { /** 查询服务器信息 */
        const res = await getServer();
        if(res.code == 200) {
          this.server = res.data;
        }
        setTimeout(() => {
          this.$modal.closeLoading();
        }, 500);
      },
      // 打开加载层
      openLoading() {
        this.$modal.loading("正在加载服务监控数据，请稍候！");
      }
    }
  }
</script>

<style lang="scss" scoped>
.server {
  
}
</style>